/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.stepapp.server;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Peter
 */
@Stateless
public class StepappUserFacade extends AbstractFacade<StepappUser> {
    @PersistenceContext(unitName = "StepAppServerPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public StepappUserFacade() {
        super(StepappUser.class);
    }

    public StepappUser findByNumber(String number) {
        StepappUser user = null;
        try {
            user = (StepappUser) em.createNamedQuery("StepappUser.findByNumber")
                .setParameter("number", number)
                .getSingleResult();
        }
        catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

        return user;
    }

    public StepappUser findByName(String name) {
        StepappUser user = null;
        try {
            user = (StepappUser) em.createNamedQuery("StepappUser.findByName")
                .setParameter("name", name)
                .getSingleResult();
        }
        catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

        return user;
    }
}
